package main
import (
	"fmt"
	"time"
)
//错误  go使用error值来表示错误状态
type MyError struct {
	When time.Time
	What string
}

func (e *MyError) Error() string {
	return fmt.Sprintf("at %v, %s",e.When, e.What)
}
func run() error {
	return &MyError{
		time.Now(),
		"it didn't work",
	}
}
func main() {
	if err := run(); err != nil {
		fmt.Println(err)//at 2023-07-19 14:00:40.585898 +0800 CST m=+0.000066664, it didn't work
	}
	
}